package com.ruoyi.dazhuwx.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.enums.OperatorType;
import com.ruoyi.dazhuwx.service.DazhuMarkersInfoService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.dazhuwx.domain.DazhuMarkersInfo;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;


/**
 * 标点信息Controller
 * 
 * @author dazhu
 * @date 2024-11-25
 */
@RestController
@RequestMapping("/dazhuwx/markersinfo")
public class DazhuMarkersInfoController extends BaseController
{
    @Autowired
    private DazhuMarkersInfoService dazhuMarkersInfoService;

    @GetMapping("test")
    public R<String> test(){
        return R.ok("小程序api调试成功！~");
    }

    /**
     * 查询标点信息列表
     */

    @GetMapping("/list")
    public TableDataInfo list(DazhuMarkersInfo dazhuMarkersInfo)
    {
        startPage();
        List<DazhuMarkersInfo> list = dazhuMarkersInfoService.list(new QueryWrapper<DazhuMarkersInfo>(dazhuMarkersInfo));
        return getDataTable(list);
    }

    /**
     * 导出标点信息列表
     */
    @PreAuthorize("@ss.hasPermi('dazhuwx:info:export')")
    @Log(title = "标点信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DazhuMarkersInfo dazhuMarkersInfo)
    {
        List<DazhuMarkersInfo> list = dazhuMarkersInfoService.list(new QueryWrapper<DazhuMarkersInfo>(dazhuMarkersInfo));
        ExcelUtil<DazhuMarkersInfo> util = new ExcelUtil<DazhuMarkersInfo>(DazhuMarkersInfo.class);
        util.exportExcel(response, list, "标点信息数据");
    }

    /**
     * 获取标点信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('dazhuwx:info:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(dazhuMarkersInfoService.getById(id));
    }

    /**
     * 新增标点信息
     */
    @Log(title = "标点信息", businessType = BusinessType.INSERT,operatorType = OperatorType.MOBILE)
    @PostMapping("/addMarkersInfo")
    public AjaxResult add(@RequestBody DazhuMarkersInfo dazhuMarkersInfo)
    {
        return toAjax(dazhuMarkersInfoService.saveAll(dazhuMarkersInfo));
    }

    /**
     * 修改标点信息
     */
    @Log(title = "标点信息", businessType = BusinessType.UPDATE)
    @PutMapping("/editMarkersInfo")
    public AjaxResult edit(@RequestBody DazhuMarkersInfo dazhuMarkersInfo)
    {
        return toAjax(dazhuMarkersInfoService.saveOrUpdate(dazhuMarkersInfo));
    }

    /**
     * 删除标点信息
     */
    @Log(title = "标点信息", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(dazhuMarkersInfoService.removeById(ids));
    }

}
